<div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
    <form data-toggle="ajaxsearch" data-options="{searchDatagrid:$.CurrentNavtab.find('#datagrid-plate-list')}">
        <fieldset>
            <legend style="font-weight:normal;">页头搜索：</legend>
            <div style="margin:0; padding:1px 5px 5px;">
                <span>版名称：</span>
                <input type="text" name="plate_name" class="form-control" size="15">

                <span>所属客户：</span>
                <input type="hidden" name="customer_id"  value="">
                <input type="text" name="customer_name" id="customer_name" data-toggle="findgrid" data-options="{
                    include: 'customer_id:id,customer_name',
                    dialogOptions: {title:'查找客户'},
                    gridOptions: {
                        local: 'local',
                        dataUrl: '/admin/customer/list',
                        columns: [
                            {name:'customer_name', label:'客户名称', width:100},
                        ]
                    }
                }" value="" disabled>

                <div class="btn-group">
                    <button type="submit" class="btn-green" data-icon="search">开始搜索！</button>
                    <button type="reset" class="btn-orange" data-icon="times">重置</button>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<div class="bjui-pageContent">
    <table class="table table-bordered" id="datagrid-plate-list" data-toggle="datagrid" data-options="{
        height: '100%',
        gridTitle : '客户列表',
        editMode: {dialog:{id:'plate-custom-save', url:'/admin/plate/custom-save', type:'get', title:'版添加', width:700, height:500}},
        local: 'remote',
        showToolbar: true,
        toolbarItem:'add,export,import',
        dataUrl: '/admin/plate/list',
        editUrl: '/admin/plate/save',
        delUrl: '/admin/plate/del',
        delPK: 'id',
        linenumberAll: true,
        sortAll: false,
        contextMenuH: true,
        contextMenuB: true,
        showCheckboxcol: true,
        inlineEditMult: true,
        paging: {showPagenum:10, selectPageSize:'20,50,100', pageCurrent:1, pageSize:20},
        customEditbtns: {width:200,position:'replace'},
        fullGrid: true,
        {{--fieldSortable: false,--}}
        sortAll:true,
        filterThead: false,
        columnMenu: false,
        exportOption:{type:'file', options:{url:'admin/plate/export', type:'get', data: {_token : '{{ csrf_token() }}'}}},
        importOption:{type:'dialog', options:{url:'admin/plate/import', width:500, height:300, type:'get', title:'导入版信息'}}
    }">
        <thead>
        <tr>
            <th data-options="{name:'plate_name',align:'center',width:100}">版名称</th>
            <th data-options="{name:'branch_number',align:'center',width:100}">支数</th>
            <th data-options="{name:'category_name',align:'center',width:100}">版分类</th>
            <th data-options="{name:'img_url', render:'create_img_tag', align:'center',width:100}">图片</th>
            <th data-options="{name:'plate_no',align:'center',width:100}">版编号</th>
            <th data-options="{name:'position',align:'center',width:100}">版位</th>
            <th data-options="{name:'factory',align:'center',width:100}">制版厂</th>
            <th data-options="{name:'factory_plate_no',align:'center',width:100}">制版厂版号</th>
            <th data-options="{name:'spec',align:'center',width:100}">规格</th>
            <th data-options="{name:'customer_name',align:'center',width:100}">所属客户</th>
            <th data-options="{name:'finish_number',align:'center',width:100}">已印刷数量</th>
            <th data-options="{name:'warning_number',align:'center',width:100}">预警数量</th>
            <th data-options="{name:'order_times',align:'center',width:100}">已印订单数</th>
            <th data-options="{name:'warning_order_times',align:'center',width:100}">预警订单数</th>
            <th data-options="{name:'last_time',align:'center',width:100}">最近印刷时间</th>
            <th data-options="{name:'warning_days',align:'center',width:100}">预警时长（天）</th>
            <th data-options="{name:'sort_id',align:'center',width:100}">排序</th>
            <th data-options="{align:'center',render:manage}">操作</th>
        </tr>
        </thead>
    </table>
</div>
<script>
    function create_img_tag(value){
        return '<img src="'+value+'" width="100" height="100">';
    }
    function manage(value,data){
        var html = '<button type="button" class="btn-green" data-toggle="dialog" data-options="{id:\'branch-dialog\',fresh:true, url:\'/admin/branch/list\', title:\'支管理\',width:800,height:800, data:{plate_id:' + data.id + '}}">支管理</button>'
                + '<button type="button" class="btn-green" data-toggle="edit.datagrid.tr">编辑</button>'
                + '<button type="button" class="btn-red" data-toggle="del.datagrid.tr">删除</button>'
        return html

    }
</script>